package com.ptszyxx.popose.module.base.login;

import android.content.Intent;
import android.os.Bundle;

import androidx.lifecycle.ViewModelProviders;

import com.ptszyxx.popose.BR;
import com.ptszyxx.popose.R;
import com.ptszyxx.popose.common.constants.BundleConstant;
import com.ptszyxx.popose.databinding.ActivityLoginBindBinding;
import com.ptszyxx.popose.module.base.login.vm.LoginBindVM;
import com.ysg.base.BaseActivity;
import com.ysg.http.data.AppViewModelFactory;

/**
 * 登录后绑定手机号
 */
public class LoginBindActivity extends BaseActivity<ActivityLoginBindBinding, LoginBindVM> {
    @Override
    public int initContentView(Bundle savedInstanceState) {
        return R.layout.activity_login_bind;
    }

    @Override
    public int initVariableId() {
        return BR.viewModel;
    }

    @Override
    public LoginBindVM initViewModel() {
        AppViewModelFactory factory = AppViewModelFactory.getInstance(getApplication());
        return ViewModelProviders.of(this, factory).get(LoginBindVM.class);
    }

    @Override
    public void initParam() {
        super.initParam();
        Intent intent = getIntent();
        if (intent != null){
            viewModel.thirdType = intent.getStringExtra(BundleConstant.THIRD_TYPE);
            viewModel.thirdToken =  intent.getStringExtra(BundleConstant.THIRD_TOKEN);
        }
    }

    @Override
    public void initViewObservable() {
        viewModel.uc.onSendCodeEvent.observe(this, o -> binding.tvSendCode.startTimeCountDown());
    }

}
